import requests
import execjs

cookies = {
    'btoken': '3I5V1CCZ4FNRZGE7RD3VO37IQXKKD45C',
    'hy_data_2020_id': '1938b94a1739cd-0c58bcc27873c1-4c657b58-2073600-1938b94a1742c5d',
    'hy_data_2020_js_sdk': '%7B%22distinct_id%22%3A%221938b94a1739cd-0c58bcc27873c1-4c657b58-2073600-1938b94a1742c5d%22%2C%22site_id%22%3A211%2C%22user_company%22%3A105%2C%22props%22%3A%7B%7D%2C%22device_id%22%3A%221938b94a1739cd-0c58bcc27873c1-4c657b58-2073600-1938b94a1742c5d%22%7D',
    'sajssdk_2020_cross_new_user': '1',
    'utoken': 'MFXXMF52QTAUOJPIZK7YTOAW4SPAC2B7',
    'username': 'Wish%E1%B5%A9',
    'export_notice': 'true',
}

headers = {
    'accept': 'application/json',
    'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
    'cache-control': 'no-cache',
    'content-type': 'application/json',
    # 'cookie': 'btoken=3I5V1CCZ4FNRZGE7RD3VO37IQXKKD45C; hy_data_2020_id=1938b94a1739cd-0c58bcc27873c1-4c657b58-2073600-1938b94a1742c5d; hy_data_2020_js_sdk=%7B%22distinct_id%22%3A%221938b94a1739cd-0c58bcc27873c1-4c657b58-2073600-1938b94a1742c5d%22%2C%22site_id%22%3A211%2C%22user_company%22%3A105%2C%22props%22%3A%7B%7D%2C%22device_id%22%3A%221938b94a1739cd-0c58bcc27873c1-4c657b58-2073600-1938b94a1742c5d%22%7D; sajssdk_2020_cross_new_user=1; utoken=MFXXMF52QTAUOJPIZK7YTOAW4SPAC2B7; username=Wish%E1%B5%A9; export_notice=true',
    'origin': 'https://www.xiniudata.com',
    'pragma': 'no-cache',
    'priority': 'u=1, i',
    'referer': 'https://www.xiniudata.com/project/lib',
    'sec-ch-ua': '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-origin',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0',
}

json_data = {
    'payload': 'LBcnV1QrNXhyGnsxWy09PVUgTlNfcHgQJSAxJTIpVj4vUjcaHGwrMCArIypaLyEuVCxRRxt+dl4sITcjJjBBJjxQLlESYmQrISA3LFEkOzNaO0NWWDw3UyRsfm8mKlw2NlxmFBIiLzsmOCwsUyA/IBB4FFJDOj9YJzo1Ky4iQW17F3Z1BX9/Gw4Se24aBwcBdW1ubnhweBAKfmQHFRZ/GnUZZnR/GxVjeHZoYBRnYQ0DBGdmbRx2Hm8YAg8ZC2IaFBdoGmB5D2sGAB8aGml3CHUVBXMMAx4QYWwHHxAGAgdlA2YUEikzOyYmKipdKzIzWj1PVVZweBAsIDo4Py1TIC5AKlJZNi8/am17I1YtICBTOk5dVzohXS4mM28LOA==',
    'sig': 'ACE83A86A7D38960C89A0B82FFB865AD',
    'v': 1,
}

response = requests.post(
    'https://www.xiniudata.com/api2/service/x_service/person_company4_list/list_companies4_list_by_codes',
    cookies=cookies,
    headers=headers,
    json=json_data,
).json()['d']

with open("Firm.js", 'r', encoding='utf-8') as f:
    js_code = f.read()


result = execjs.compile(js_code).call('f',response)
# print(response)
print(result)